package br.mikhas.lang.struct;

import java.util.ArrayList;
import java.util.List;

public class Type {

	protected List<Type> types;
	protected Class cls;

	private Type(Type... types) {
		this.types = new ArrayList<Type>(types.length);
		for (Type type : types)
			this.types.add(type);
	}

	private Type(Class cls) {
		this.cls = cls;
	}

	private Type(Class... classes) {
		types = new ArrayList<Type>(classes.length);
		for (Class cls : classes)
			types.add(new Type(cls));

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((cls == null) ? 0 : cls.hashCode());
		result = prime * result + ((types == null) ? 0 : types.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Type other = (Type) obj;
		if (cls == null) {
			if (other.cls != null)
				return false;
		} else if (!cls.equals(other.cls))
			return false;
		if (types == null) {
			if (other.types != null)
				return false;
		} else if (!types.equals(other.types))
			return false;
		return true;
	}

}
